<?php
if(!defined("BASE_LIB_DIR")){
    define("BASE_LIB_DIR",dirname(dirname(__FILE__))."/libs");
}
if(!defined("BASE_CONF_DIR")){
    define("BASE_CONF_DIR",dirname(dirname(__FILE__))."/conf");
}

require_once(BASE_CONF_DIR.'/config.php');

require_once(BASE_LIB_DIR.'/view_func.php');
require_once(BASE_LIB_DIR.'/twitter_func.php');
require_once(BASE_LIB_DIR.'/proxy_func.php');
require_once(BASE_LIB_DIR.'/tweet_rating.php');
require_once(BASE_LIB_DIR.'/global_func.php');
require_once(BASE_LIB_DIR.'/smarty/smartyTemplate.class.php');

//formate smarty object.
$smarty = &new smartyTemplate(BASE_TEMPLATES_DIR,SMARTY_TEMPLATES_C,SMARTY_CACHE_DIR);
//init smarty variables.
$smarty->assign("charset",SYSTEM_CHARSET);
$smarty->assign("lang",SYSTEM_LANG);
$smarty->assign("res",RES_PATH);
$smarty->assign("www",WWW_PATH);


if(isset($_POST['password'])) {
    setcookie("password",$_POST['password'],time()+60*60*24*30);
    setcookie("username",$_POST['username'],time()+60*60*24*30);
    header("Location: index.php");
} else {
    setcookie("password","");
    setcookie("username","");
    $user_os = getUserOS();
    if($user_os == "other"){
        $smarty->display("mobile/login.tpl");
    }else{
        $smarty->display("pc/login.tpl");
    }
}
?>